home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Database / SimpleTableView-1 / SimpleTableView.m < prev   
Text File  |  1995-06-12  |  2KB  |  79 lines

  1. // -------------------------------------------------------------------------------------
  2. //  SimpleTableView app
  3. //  This software is without warranty of any kind.  Use at your own risk.
  4. // -------------------------------------------------------------------------------------
  5.  
  6. #import <appkit/appkit.h>
  7. #import <objc/objc.h>
  8. #import <libc.h>
  9. #import <stdlib.h>
  10. #import <string.h>
  11. #import <c.h>
  12. #import <ctype.h>
  13. #import <sys/param.h>
  14. #import <sys/types.h>
  15. #import <sys/time.h>
  16. #import <sys/dir.h>
  17. #import "SimpleTableView.h"
  18. #import "DataEditor.h"
  19.  
  20. // -------------------------------------------------------------------------------------
  21. @implementation SimpleTableView
  22.  
  23. // -------------------------------------------------------------------------------------
  24. // menu actions
  25.  
  26. /* open table file */
  27. - openTable:sender
  28. {
  29.     id            pOpen;
  30.     char        fName[MAXPATHLEN+1], *dir, **files, *fTypes[] = { "simpleTbl", 0 };
  31.  
  32.     /* build/display open panel */
  33.     pOpen = [OpenPanel new];
  34.     [pOpen setTitle:"Open Simple DataTable"];
  35.     [pOpen setPrompt:"File:"];
  36.     [pOpen setRequiredFileType:fTypes[0]];
  37.     [pOpen allowMultipleFiles:YES];
  38.     [pOpen setDirectory:pathToApp];
  39.     if (![pOpen runModalForTypes:fTypes]) return self;
  40.  
  41.     /* open the list of selected files */
  42.     if (!(files = (char**)[pOpen filenames])) return self;
  43.     dir = (char*)[pOpen directory];
  44.     while (*files) {
  45.         sprintf(fName, "%s/%s", dir, *files++);
  46.         [[DataEditor alloc] initFromFile:fName];
  47.     }
  48.     
  49.     return self;
  50. }
  51.  
  52. /* terminate */
  53. - terminate:sender
  54. {
  55.     [DataEditor terminateAllEditors];
  56.     return [super terminate:sender];
  57. }
  58.  
  59. // -------------------------------------------------------------------------------------
  60. // application initialization 
  61.  
  62. /* app did initialize */
  63. - appDidInit:sender
  64. {
  65.     char *p, path[MAXPATHLEN + 1];
  66.     if (NXArgv[0][0] == '/') strcpy(path, NXArgv[0]);
  67.     else { 
  68.         getwd(path);
  69.         strcat(path, "/");
  70.         strcat(path, NXArgv[0]);
  71.     }
  72.     if ((p = rindex(path, '/')) && (p != path)) *p = 0;
  73.     pathToApp = NXCopyStringBuffer(path);
  74.     return self;
  75. }
  76.  
  77. // -------------------------------------------------------------------------------------
  78. @end
  79.